home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Power 1997 December
/
MACPOWER-1997-12.ISO.7z
/
MACPOWER-1997-12.ISO
/
AMUG
/
PROGRAMMING
/
Raven 1.2 Examples.sit
/
Raven 1.2 Examples
/
Quill
/
Source
/
ViewCommands.cpp
< prev
next >
Wrap
Text File
|
1997-08-07
|
34KB
|
1,406 lines
/*
* File: ViewCommands.cpp
* Summary: Command objects for manipulating views.
* Written by: Jesse Jones
*
* Copyright ゥ 1996-1997 Jesse Jones.
* For conditions of distribution and use, see copyright notice in ZTypes.h
*
* Change History (most recent first):
*
* <2> 4/06/97 JDJ Updated for new style TSubPaneIterator.
* <1> 8/29/96 JDJ Created
*/
#include "ViewCommands.h"
#include <Limits.h>
#include <List.h>
#include <Scrap.h>
#include <ZHandleStream.h>
#include <ZMiscUtils.h>
#include <ZScrap.h>
#include <ZStringUtils.h>
#include <ZUndoMgr.h>
#include "ViewContainer.h"
// ===================================================================================
// class CResizePaneCommand
// ===================================================================================
//---------------------------------------------------------------
//
// CResizePaneCommand::~CResizePaneCommand
//
//---------------------------------------------------------------
CResizePaneCommand::~CResizePaneCommand()
{
}
//---------------------------------------------------------------
//
// CResizePaneCommand::CResizePaneCommand (TPane*, TRect)
//
//---------------------------------------------------------------
CResizePaneCommand::CResizePaneCommand(TPane* pane, const TRect& newFrame) : mPane(pane)
{
ASSERT(pane != nil);
mOldFrame = mPane->GetFrame();
mNewFrame = newFrame;
TView* superView = mPane->GetSuperView();
mContainer = dynamic_cast<CViewContainer*>(superView);
while (mContainer == nil && superView != nil) {
superView = superView->GetSuperView();
mContainer = dynamic_cast<CViewContainer*>(superView);
}
ASSERT(mContainer != nil);
}
//---------------------------------------------------------------
//
// CResizePaneCommand::CResizePaneCommand (TPane*, TRect, TRect)
//
//---------------------------------------------------------------
CResizePaneCommand::CResizePaneCommand(TPane* pane, const TRect& oldFrame, const TRect& newFrame) : mPane(pane)
{
ASSERT(pane != nil);
ASSERT(oldFrame != newFrame);
mOldFrame = oldFrame;
mNewFrame = newFrame;
TView* superView = mPane->GetSuperView();
mContainer = dynamic_cast<CViewContainer*>(superView);
while (mContainer == nil && superView != nil) {
superView = superView->GetSuperView();
mContainer = dynamic_cast<CViewContainer*>(superView);
}
ASSERT(mContainer != nil);
}
//---------------------------------------------------------------
//
// CResizePaneCommand::GetText
//
//---------------------------------------------------------------
string CResizePaneCommand::GetText() const
{
return LoadIndString(256, 15);
}
//---------------------------------------------------------------
//
// CResizePaneCommand::IsValid
//
//---------------------------------------------------------------
bool CResizePaneCommand::IsValid() const
{
return mPane.TargetExists();
}
//---------------------------------------------------------------
//
// CResizePaneCommand::OnDo
//
//---------------------------------------------------------------
void CResizePaneCommand::OnDo()
{
mContainer->Select(nil);
mPane->SetFrame(mNewFrame);
mContainer->Select(mPane.Get());
mContainer->UpdateResource();
}
//---------------------------------------------------------------
//
// CResizePaneCommand::OnUndo
//
//---------------------------------------------------------------
void CResizePaneCommand::OnUndo()
{
mContainer->Select(nil);
mPane->SetFrame(mOldFrame);
mContainer->Select(mPane.Get());
mContainer->UpdateResource();
}
//---------------------------------------------------------------
//
// CResizePaneCommand::OnRedo
//
//---------------------------------------------------------------
void CResizePaneCommand::OnRedo()
{
mContainer->Select(nil);
mPane->SetFrame(mNewFrame);
mContainer->Select(mPane.Get());
mContainer->UpdateResource();
}
#pragma mark -
// ===================================================================================
// class CPaneEditCommand
// ===================================================================================
//---------------------------------------------------------------
//
// CPaneEditCommand::~CPaneEditCommand
//
//---------------------------------------------------------------
CPaneEditCommand::~CPaneEditCommand()
{
delete mPanes;
}
//---------------------------------------------------------------
//
// CPaneEditCommand::CPaneEditCommand (CViewContainer*, bool)
//
//---------------------------------------------------------------
CPaneEditCommand::CPaneEditCommand(CViewContainer* container, bool addSelection)
{
ASSERT(container != nil);
mContainer = container;
mPanes = new list<SInfo, allocator<SInfo> >;
if (addSelection) {
try {
TSubPaneIterator iter = mContainer->begin(kRecursive);
while (iter != mContainer->end()) {
TPane* pane = *iter;
++iter;
if (mContainer->IsSelected(pane))
mPanes->push_back(pane);
}
} catch (...) {
delete mPanes;
throw;
}
}
}
//---------------------------------------------------------------
//
// CPaneEditCommand::CPaneEditCommand (CViewContainer*, TUndoMgr*, bool)
//
//---------------------------------------------------------------
CPaneEditCommand::CPaneEditCommand(CViewContainer* container, TUndoMgr* context, bool addSelection) : TUndoableCommand(context)
{
ASSERT(container != nil);
mContainer = container;
mPanes = new list<SInfo, allocator<SInfo> >;
if (addSelection) {
try {
TSubPaneIterator iter = mContainer->begin(kRecursive);
while (iter != mContainer->end()) {
TPane* pane = *iter;
++iter;
if (mContainer->IsSelected(pane))
mPanes->push_back(pane);
}
} catch (...) {
delete mPanes;
throw;
}
}
}
//---------------------------------------------------------------
//
// CPaneEditCommand::IsValid
//
//---------------------------------------------------------------
bool CPaneEditCommand::IsValid() const
{
bool valid = true;
list<SInfo, allocator<SInfo> >::const_iterator iter = mPanes->begin();
while (iter != mPanes->end() && valid) {
const SInfo& info = *iter++;
valid = info.pane.TargetExists() && info.super.TargetExists();
}
return valid;
}
#pragma mark -
// ===================================================================================
// class CAddPanesCommand
// ===================================================================================
//---------------------------------------------------------------
//
// CAddPanesCommand::~CAddPanesCommand
//
//---------------------------------------------------------------
CAddPanesCommand::~CAddPanesCommand()
{
list<SInfo, allocator<SInfo> >::iterator iter = mPanes->begin();
while (iter != mPanes->end()) {
SInfo& info = *iter++;
if (info.pane.TargetExists() && info.pane->GetSuperView() == nil)
delete info.pane.Get();
}
}
//---------------------------------------------------------------
//
// CAddPanesCommand::CAddPanesCommand (CViewContainer*, bool)
//
//---------------------------------------------------------------
CAddPanesCommand::CAddPanesCommand(CViewContainer* container, bool addSelection) : CPaneEditCommand(container, addSelection)
{
}
//---------------------------------------------------------------
//
// CAddPanesCommand::CAddPanesCommand (CViewContainer*, TUndoMgr*, bool)
//
//---------------------------------------------------------------
CAddPanesCommand::CAddPanesCommand(CViewContainer* container, TUndoMgr* context, bool addSelection) : CPaneEditCommand(container, context, addSelection)
{
}
//---------------------------------------------------------------
//
// CAddPanesCommand::OnAdd
//
//---------------------------------------------------------------
void CAddPanesCommand::OnAdd()
{
mContainer->Select(nil);
list<SInfo, allocator<SInfo> >::iterator iter = mPanes->begin();
while (iter != mPanes->end()) {
SInfo& info = *iter++;
info.super->AddSubPane(info.pane.Get());
mContainer->Select(info.pane.Get(), true);
}
mContainer->UpdateResource();
}
//---------------------------------------------------------------
//
// CAddPanesCommand::OnRemove
//
//---------------------------------------------------------------
void CAddPanesCommand::OnRemove()
{
mContainer->Select(nil);
list<SInfo, allocator<SInfo> >::iterator iter = mPanes->begin();
while (iter != mPanes->end()) {
SInfo& info = *iter++;
info.super->RemoveSubPane(info.pane.Get());
}
mContainer->UpdateResource();
}
#pragma mark -
// ===================================================================================
// class CAddSubPanesCommand
// ===================================================================================
//---------------------------------------------------------------
//
// CAddSubPanesCommand::~CAddSubPanesCommand
//
//---------------------------------------------------------------
CAddSubPanesCommand::~CAddSubPanesCommand()
{
}
//---------------------------------------------------------------
//
// CAddSubPanesCommand::CAddSubPanesCommand
//
//---------------------------------------------------------------
CAddSubPanesCommand::CAddSubPanesCommand(CViewContainer* container, TView* superView, TUndoMgr* context) : CAddPanesCommand(container, context, false)
{
ASSERT(superView != nil);
mSuper = superView;
}
//---------------------------------------------------------------
//
// CAddSubPanesCommand::AddPane
//
//---------------------------------------------------------------
void CAddSubPanesCommand::AddPane(TPane* pane)
{
ASSERT(pane != nil);
SInfo info(pane);
info.super = mSuper;
mPanes->push_back(info);
}
//---------------------------------------------------------------
//
// CAddSubPanesCommand::GetText
//
//---------------------------------------------------------------
string CAddSubPanesCommand::GetText() const
{
return LoadIndString(256, 11);
}
//---------------------------------------------------------------
//
// CAddSubPanesCommand::OnDo
//
//---------------------------------------------------------------
void CAddSubPanesCommand::OnDo()
{
this->OnAdd();
}
//---------------------------------------------------------------
//
// CAddSubPanesCommand::OnUndo
//
//---------------------------------------------------------------
void CAddSubPanesCommand::OnUndo()
{
this->OnRemove();
}
//---------------------------------------------------------------
//
// CAddSubPanesCommand::OnRedo
//
//---------------------------------------------------------------
void CAddSubPanesCommand::OnRedo()
{
this->OnAdd();
}
#pragma mark -
// ===================================================================================
// class CDeletePanesCommand
// ===================================================================================
//---------------------------------------------------------------
//
// CDeletePanesCommand::~CDeletePanesCommand
//
//---------------------------------------------------------------
CDeletePanesCommand::~CDeletePanesCommand()
{
}
//---------------------------------------------------------------
//
// CDeletePanesCommand::CDeletePanesCommand
//
//---------------------------------------------------------------
CDeletePanesCommand::CDeletePanesCommand(CViewContainer* container) : CAddPanesCommand(container)
{
}
//---------------------------------------------------------------
//
// CDeletePanesCommand::GetText
//
//---------------------------------------------------------------
string CDeletePanesCommand::GetText() const
{
return LoadIndString(256, 7);
}
//---------------------------------------------------------------
//
// CDeletePanesCommand::OnDo
//
//---------------------------------------------------------------
void CDeletePanesCommand::OnDo()
{
this->OnRemove();
}
//---------------------------------------------------------------
//
// CDeletePanesCommand::OnUndo
//
//---------------------------------------------------------------
void CDeletePanesCommand::OnUndo()
{
this->OnAdd();
}
//---------------------------------------------------------------
//
// CDeletePanesCommand::OnRedo
//
//---------------------------------------------------------------
void CDeletePanesCommand::OnRedo()
{
this->OnRemove();
}
#pragma mark -
// ===================================================================================
// class CDuplicatePanesCommand
// ===================================================================================
//---------------------------------------------------------------
//
// CDuplicatePanesCommand::~CDuplicatePanesCommand
//
//---------------------------------------------------------------
CDuplicatePanesCommand::~CDuplicatePanesCommand()
{
}
//---------------------------------------------------------------
//
// CDuplicatePanesCommand::CDuplicatePanesCommand
//
//---------------------------------------------------------------
CDuplicatePanesCommand::CDuplicatePanesCommand(CViewContainer* container) : CAddPanesCommand(container)
{
list<SInfo, allocator<SInfo> >::iterator iter = mPanes->begin();
while (iter != mPanes->end()) {
SInfo& info = *iter++;
THandle data;
{
TOutHandleStream stream(data);
info.pane->Externalize(stream);
}
{
TInHandleStream stream(data);
info.pane = TPane::Create(stream, info.super.Get());
mContainer->DecoratePane(info.pane.Get());
mContainer->Select(info.pane.Get(), true);
TPoint loc = info.pane->GetLocation();
info.pane->SetLocation(loc + TPoint(16, 16));
info.super->RemoveSubPane(info.pane.Get());
}
}
}
//---------------------------------------------------------------
//
// CDuplicatePanesCommand::GetText
//
//---------------------------------------------------------------
string CDuplicatePanesCommand::GetText() const
{
return LoadIndString(256, 9);
}
//---------------------------------------------------------------
//
// CDuplicatePanesCommand::OnDo
//
//---------------------------------------------------------------
void CDuplicatePanesCommand::OnDo()
{
this->OnAdd();
}
//---------------------------------------------------------------
//
// CDuplicatePanesCommand::OnUndo
//
//---------------------------------------------------------------
void CDuplicatePanesCommand::OnUndo()
{
this->OnRemove();
}
//---------------------------------------------------------------
//
// CDuplicatePanesCommand::OnRedo
//
//---------------------------------------------------------------
void CDuplicatePanesCommand::OnRedo()
{
this->OnAdd();
}
#pragma mark -
// ===================================================================================
// class CMovePanesCommand
// ===================================================================================
//---------------------------------------------------------------
//
// CMovePanesCommand::~CMovePanesCommand
//
//---------------------------------------------------------------
CMovePanesCommand::~CMovePanesCommand()
{
}
//---------------------------------------------------------------
//
// CMovePanesCommand::CMovePanesCommand
//
//---------------------------------------------------------------
CMovePanesCommand::CMovePanesCommand(CViewContainer* container, TView* newSuper, TUndoMgr* context) : CPaneEditCommand(container, context, false)
{
ASSERT(newSuper != nil);
mNewSuper = newSuper;
}
//---------------------------------------------------------------
//
// CMovePanesCommand::AddPane
//
//---------------------------------------------------------------
void CMovePanesCommand::AddPane(TPane* pane, const TPoint& newLoc)
{
ASSERT(pane != nil);
SInfo info(pane);
info.newInfo.loc = newLoc;
mPanes->push_back(info);
}
//---------------------------------------------------------------
//
// CMovePanesCommand::GetText
//
//---------------------------------------------------------------
string CMovePanesCommand::GetText() const
{
return LoadIndString(256, 13);
}
//---------------------------------------------------------------
//
// CMovePanesCommand::OnDo
//
//---------------------------------------------------------------
void CMovePanesCommand::OnDo()
{
this->OnRedo();
}
//---------------------------------------------------------------
//
// CMovePanesCommand::OnUndo
//
//---------------------------------------------------------------
void CMovePanesCommand::OnUndo()
{
mContainer->Select(nil);
list<SInfo, allocator<SInfo> >::iterator iter = mPanes->begin();
while (iter != mPanes->end()) {
SInfo& info = *iter++;
if (info.super != mNewSuper) {
mNewSuper->RemoveSubPane(info.pane.Get());
info.super->AddSubPane(info.pane.Get());
}
info.pane->SetLocation(info.oldInfo.loc);
mContainer->Select(info.pane.Get(), true);
}
mContainer->UpdateResource();
}
//---------------------------------------------------------------
//
// CMovePanesCommand::OnRedo
//
//---------------------------------------------------------------
void CMovePanesCommand::OnRedo()
{
mContainer->Select(nil);
list<SInfo, allocator<SInfo> >::iterator iter = mPanes->begin();
while (iter != mPanes->end()) {
SInfo& info = *iter++;
if (info.super != mNewSuper) {
info.super->RemoveSubPane(info.pane.Get());
mNewSuper->AddSubPane(info.pane.Get());
}
info.pane->SetLocation(info.newInfo.loc);
mContainer->Select(info.pane.Get(), true);
}
mContainer->UpdateResource();
}
#pragma mark -
// ===================================================================================
// class CCopyPanesCommand
// ===================================================================================
//---------------------------------------------------------------
//
// CCopyPanesCommand::~CCopyPanesCommand
//
//---------------------------------------------------------------
CCopyPanesCommand::~CCopyPanesCommand()
{
}
//---------------------------------------------------------------
//
// CCopyPanesCommand::CCopyPanesCommand
//
//---------------------------------------------------------------
CCopyPanesCommand::CCopyPanesCommand(CViewContainer* container) : CAddPanesCommand(container)
{
}
//---------------------------------------------------------------
//
// CCopyPanesCommand::GetText
//
//---------------------------------------------------------------
string CCopyPanesCommand::GetText() const
{
return LoadIndString(256, 3);
}
//---------------------------------------------------------------
//
// CCopyPanesCommand::OnDo
//
//---------------------------------------------------------------
void CCopyPanesCommand::OnDo()
{
TOutHandleStream stream;
list<SInfo, allocator<SInfo> >::iterator iter = mPanes->begin();
while (iter != mPanes->end()) {
SInfo& info = *iter++;
TPane* pane = info.pane.Get();
{
TOutHandleStream tempStream;
pane->Externalize(tempStream);
SResource rsrc(kIndeterminateID, "", tempStream.GetHandle());
stream << rsrc;
}
}
mOldScrap = ::GetScrap();
::ZeroScrap();
::PutScrap('View', stream.GetHandle());
mNewScrap = ::GetScrap();
}
//---------------------------------------------------------------
//
// CCopyPanesCommand::OnUndo
//
//---------------------------------------------------------------
void CCopyPanesCommand::OnUndo()
{
::SetScrap(mOldScrap);
}
//---------------------------------------------------------------
//
// CCopyPanesCommand::OnRedo
//
//---------------------------------------------------------------
void CCopyPanesCommand::OnRedo()
{
::SetScrap(mNewScrap);
}
#pragma mark -
// ===================================================================================
// class CCutPanesCommand
// ===================================================================================
//---------------------------------------------------------------
//
// CCutPanesCommand::~CCutPanesCommand
//
//---------------------------------------------------------------
CCutPanesCommand::~CCutPanesCommand()
{
}
//---------------------------------------------------------------
//
// CCutPanesCommand::CCutPanesCommand
//
//---------------------------------------------------------------
CCutPanesCommand::CCutPanesCommand(CViewContainer* container) : CCopyPanesCommand(container)
{
}
//---------------------------------------------------------------
//
// CCutPanesCommand::GetText
//
//---------------------------------------------------------------
string CCutPanesCommand::GetText() const
{
return LoadIndString(256, 1);
}
//---------------------------------------------------------------
//
// CCutPanesCommand::OnDo
//
//---------------------------------------------------------------
void CCutPanesCommand::OnDo()
{
Inherited::OnDo();
this->OnRemove();
}
//---------------------------------------------------------------
//
// CCutPanesCommand::OnUndo
//
//---------------------------------------------------------------
void CCutPanesCommand::OnUndo()
{
Inherited::OnUndo();
this->OnAdd();
}
//---------------------------------------------------------------
//
// CCutPanesCommand::OnRedo
//
//---------------------------------------------------------------
void CCutPanesCommand::OnRedo()
{
Inherited::OnRedo();
this->OnRemove();
}
#pragma mark -
// ===================================================================================
// class CPastePanesCommand
// ===================================================================================
//---------------------------------------------------------------
//
// CPastePanesCommand::~CPastePanesCommand
//
//---------------------------------------------------------------
CPastePanesCommand::~CPastePanesCommand()
{
}
//---------------------------------------------------------------
//
// CPastePanesCommand::CPastePanesCommand
//
//---------------------------------------------------------------
CPastePanesCommand::CPastePanesCommand(CViewContainer* container, TView* superView) : CAddPanesCommand(container, false)
{
ASSERT(superView != nil);
mSuper = superView;
}
//---------------------------------------------------------------
//
// CPastePanesCommand::GetText
//
//---------------------------------------------------------------
string CPastePanesCommand::GetText() const
{
return LoadIndString(256, 5);
}
//---------------------------------------------------------------
//
// CPastePanesCommand::OnDo
//
//---------------------------------------------------------------
void CPastePanesCommand::OnDo()
{
mContainer->Select(nil);
THandle data = ::GetScrap('View');
TInHandleStream stream(data);
while (!stream.AtEnd()) {
SResource rsrc;
stream >> rsrc;
{
TInHandleStream tempStream(rsrc.data);
TPane* pane = TPane::Create(tempStream, mSuper);
mContainer->DecoratePane(pane);
mContainer->Select(pane);
mPanes->push_back(pane);
}
}
mContainer->UpdateResource();
}
//---------------------------------------------------------------
//
// CPastePanesCommand::OnUndo
//
//---------------------------------------------------------------
void CPastePanesCommand::OnUndo()
{
this->OnRemove();
}
//---------------------------------------------------------------
//
// CPastePanesCommand::OnRedo
//
//---------------------------------------------------------------
void CPastePanesCommand::OnRedo()
{
this->OnAdd();
}
#pragma mark -
// ===================================================================================
// class COffsetPanesCommand
// ===================================================================================
//---------------------------------------------------------------
//
// COffsetPanesCommand::~COffsetPanesCommand
//
//---------------------------------------------------------------
COffsetPanesCommand::~COffsetPanesCommand()
{
}
//---------------------------------------------------------------
//
// COffsetPanesCommand::COffsetPanesCommand
//
//---------------------------------------------------------------
COffsetPanesCommand::COffsetPanesCommand(CViewContainer* container) : CPaneEditCommand(container)
{
}
//---------------------------------------------------------------
//
// COffsetPanesCommand::OnDo
//
//---------------------------------------------------------------
void COffsetPanesCommand::OnDo()
{
this->OnRedo();
}
//---------------------------------------------------------------
//
// COffsetPanesCommand::OnUndo
//
//---------------------------------------------------------------
void COffsetPanesCommand::OnUndo()
{
mContainer->Select(nil);
list<SInfo, allocator<SInfo> >::iterator iter = mPanes->begin();
while (iter != mPanes->end()) {
SInfo& info = *iter++;
info.pane->SetLocation(info.oldInfo.loc);
mContainer->Select(info.pane.Get(), true);
}
mContainer->UpdateResource();
}
//---------------------------------------------------------------
//
// COffsetPanesCommand::OnRedo
//
//---------------------------------------------------------------
void COffsetPanesCommand::OnRedo()
{
mContainer->Select(nil);
list<SInfo, allocator<SInfo> >::iterator iter = mPanes->begin();
while (iter != mPanes->end()) {
SInfo& info = *iter++;
info.pane->SetLocation(info.newInfo.loc);
mContainer->Select(info.pane.Get(), true);
}
mContainer->UpdateResource();
}
#pragma mark -
// ===================================================================================
// class CNudgePaneCommand
// ===================================================================================
//---------------------------------------------------------------
//
// CNudgePaneCommand::~CNudgePaneCommand
//
//---------------------------------------------------------------
CNudgePaneCommand::~CNudgePaneCommand()
{
}
//---------------------------------------------------------------
//
// CNudgePaneCommand::CNudgePaneCommand
//
//---------------------------------------------------------------
CNudgePaneCommand::CNudgePaneCommand(CViewContainer* container, char key) : COffsetPanesCommand(container)
{
ASSERT(key == kLeftArrowChar || key == kRightArrowChar || key == kUpArrowChar || key == kDownArrowChar);
mKey = key;
mExecuted = false;
}
//---------------------------------------------------------------
//
// CNudgePaneCommand::CanNudge
//
//---------------------------------------------------------------
bool CNudgePaneCommand::CanNudge(CViewContainer* container, char key) const
{
bool can = false;
if (container == mContainer && key == mKey) {
if (TUndoMgr::GetContext()->GetUndoCommand() == this) {
if (!TUndoMgr::GetContext()->CanRedo()) {
if (!mExecuted) {
can = true;
TSubPaneIterator iter = mContainer->begin(kRecursive); // make sure the selection hasn't changed
while (iter != mContainer->end() && can) {
TPane* pane = *iter;
++iter;
if (mContainer->IsSelected(pane)) {
if (find(mPanes->begin(), mPanes->end(), pane) == mPanes->end())
can = false;
} else {
if (find(mPanes->begin(), mPanes->end(), pane) != mPanes->end())
can = false;
}
}
}
}
}
}
return can;
}
//---------------------------------------------------------------
//
// CNudgePaneCommand::Nudge
//
//---------------------------------------------------------------
void CNudgePaneCommand::Nudge()
{
list<SInfo, allocator<SInfo> >::iterator iter = mPanes->begin();
while (iter != mPanes->end()) {
SInfo& info = *iter++;
TPoint delta = kZeroPt;
switch (mKey) {
case kLeftArrowChar:
delta.h = -1;
break;
case kRightArrowChar:
delta.h = +1;
break;
case kUpArrowChar:
delta.v = -1;
break;
case kDownArrowChar:
delta.v = +1;
break;
}
info.newInfo.loc += delta;
info.pane->SetLocation(info.newInfo.loc);
}
}
//---------------------------------------------------------------
//
// CNudgePaneCommand::GetText
//
//---------------------------------------------------------------
string CNudgePaneCommand::GetText() const
{
return LoadIndString(256, 23);
}
//---------------------------------------------------------------
//
// CNudgePaneCommand::OnDo
//
//---------------------------------------------------------------
void CNudgePaneCommand::OnDo()
{
// handled by Nudge
}
//---------------------------------------------------------------
//
// CNudgePaneCommand::OnUndo
//
//---------------------------------------------------------------
void CNudgePaneCommand::OnUndo()
{
Inherited::OnUndo();
mExecuted = true;
}
//---------------------------------------------------------------
//
// CNudgePaneCommand::OnRedo
//
//---------------------------------------------------------------
void CNudgePaneCommand::OnRedo()
{
Inherited::OnRedo();
mExecuted = true;
}
#pragma mark -
// ===================================================================================
// class CAlignLeftCommand
// ===================================================================================
//---------------------------------------------------------------
//
// CAlignLeftCommand::~CAlignLeftCommand
//
//---------------------------------------------------------------
CAlignLeftCommand::~CAlignLeftCommand()
{
}
//---------------------------------------------------------------
//
// CAlignLeftCommand::CAlignLeftCommand
//
//---------------------------------------------------------------
CAlignLeftCommand::CAlignLeftCommand(CViewContainer* container) : COffsetPanesCommand(container)
{
short peg = SHRT_MAX;
list<SInfo, allocator<SInfo> >::iterator iter = mPanes->begin();
while (iter != mPanes->end()) {
SInfo& info = *iter++;
if (info.oldInfo.loc.h < peg)
peg = info.oldInfo.loc.h;
}
iter = mPanes->begin();
while (iter != mPanes->end()) {
SInfo& info = *iter++;
info.newInfo.loc.h = peg;
}
}
//---------------------------------------------------------------
//
// CAlignLeftCommand::GetText
//
//---------------------------------------------------------------
string CAlignLeftCommand::GetText() const
{
return LoadIndString(256, 24);
}
#pragma mark -
// ===================================================================================
// class CAlignRightCommand
// ===================================================================================
//---------------------------------------------------------------
//
// CAlignRightCommand::~CAlignRightCommand
//
//---------------------------------------------------------------
CAlignRightCommand::~CAlignRightCommand()
{
}
//---------------------------------------------------------------
//
// CAlignRightCommand::CAlignRightCommand
//
//---------------------------------------------------------------
CAlignRightCommand::CAlignRightCommand(CViewContainer* container) : COffsetPanesCommand(container)
{
short peg = SHRT_MIN;
list<SInfo, allocator<SInfo> >::iterator iter = mPanes->begin();
while (iter != mPanes->end()) {
SInfo& info = *iter++;
if (info.oldInfo.loc.h > peg)
peg = info.oldInfo.loc.h;
}
iter = mPanes->begin();
while (iter != mPanes->end()) {
SInfo& info = *iter++;
info.newInfo.loc.h = peg;
}
}
//---------------------------------------------------------------
//
// CAlignRightCommand::GetText
//
//---------------------------------------------------------------
string CAlignRightCommand::GetText() const
{
return LoadIndString(256, 25);
}
#pragma mark -
// ===================================================================================
// class CAlignTopCommand
// ===================================================================================
//---------------------------------------------------------------
//
// CAlignTopCommand::~CAlignTopCommand
//
//---------------------------------------------------------------
CAlignTopCommand::~CAlignTopCommand()
{
}
//---------------------------------------------------------------
//
// CAlignTopCommand::CAlignTopCommand
//
//---------------------------------------------------------------
CAlignTopCommand::CAlignTopCommand(CViewContainer* container) : COffsetPanesCommand(container)
{
short peg = SHRT_MAX;
list<SInfo, allocator<SInfo> >::iterator iter = mPanes->begin();
while (iter != mPanes->end()) {
SInfo& info = *iter++;
if (info.oldInfo.loc.v < peg)
peg = info.oldInfo.loc.v;
}
iter = mPanes->begin();
while (iter != mPanes->end()) {
SInfo& info = *iter++;
info.newInfo.loc.v = peg;
}
}
//---------------------------------------------------------------
//
// CAlignTopCommand::GetText
//
//---------------------------------------------------------------
string CAlignTopCommand::GetText() const
{
return LoadIndString(256, 26);
}
#pragma mark -
// ===================================================================================
// class CAlignBottomCommand
// ===================================================================================
//---------------------------------------------------------------
//
// CAlignBottomCommand::~CAlignBottomCommand
//
//---------------------------------------------------------------
CAlignBottomCommand::~CAlignBottomCommand()
{
}
//---------------------------------------------------------------
//
// CAlignBottomCommand::CAlignBottomCommand
//
//---------------------------------------------------------------
CAlignBottomCommand::CAlignBottomCommand(CViewContainer* container) : COffsetPanesCommand(container)
{
short peg = SHRT_MIN;
list<SInfo, allocator<SInfo> >::iterator iter = mPanes->begin();
while (iter != mPanes->end()) {
SInfo& info = *iter++;
if (info.oldInfo.loc.v > peg)
peg = info.oldInfo.loc.v;
}
iter = mPanes->begin();
while (iter != mPanes->end()) {
SInfo& info = *iter++;
info.newInfo.loc.v = peg;
}
}
//---------------------------------------------------------------
//
// CAlignBottomCommand::GetText
//
//---------------------------------------------------------------
string CAlignBottomCommand::GetText() const
{
return LoadIndString(256, 27);
}